package com.amex.uam.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.amex.uam.model.Message;
import com.amex.uam.service.ProjService;
import com.amex.uam.util.Utils;
import com.microstrategy.web.beans.RequestKeys;

@Controller("projAction")
public class ProjAction {

	private ProjService projService;

	@Resource
	public void setProjService(ProjService projService) {
		this.projService = projService;
	}

	public Message loadAllProjects() {
		return projService.loadAllProjects();
	}

	public Message loadUserProjects(RequestKeys keys) {
		String amexWebId = Utils.trim(keys.getValue("amexWebId"), null);
		String userId = Utils.trim(keys.getValue("userId"), null);
		
		if (amexWebId != null) {
			return loadUserProjByMemberID(amexWebId);
		} else {
			return loadUserProjByUserID(userId);
		}
	}
	
	public Message loadUserProjByMemberID(String amexWebId){
		return projService.getUserProjByMemberID(amexWebId);
	}
	public Message loadUserProjByUserID(String userId) {
		return projService.getUserProjByUserID(userId);
	}

}
